package cn.edu.zust.se.dao;
import cn.edu.zust.se.model.Picture;
import org.apache.ibatis.annotations.*;
import java.util.Date;
import java.util.List;

public interface PictureMapper {
    @Insert("INSERT INTO picture(name, frame, user_id, intro, tags, upload_time, click_num) " +
            "VALUES(#{name}, #{frame}, #{userId}, #{intro}, #{tags}, #{uploadTime}, #{clickNum})")
    void addPicture(Picture picture);

    @Select("SELECT * FROM picture WHERE user_id=#{userId}")
    List<Picture> listUserPictures(Integer userId);

    @Select("SELECT * FROM picture WHERE user_id=#{userId} AND upload_time BETWEEN #{startTime} AND #{endTime}")
    List<Picture> listUserPicturesByTime(@Param("userId") Integer userId, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
}